<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>彩投注站彩票投注助手</title>
    <style type="text/css">
        html, body {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
        }

        .header {
            width: 100%;
            height: 20%;
            display: flex;
            justify-content: space-between;
        }

        .title {
            height: 10%;
        }

        h1 {
            margin: 0;
        }

        .content {
            width: 100%;
            height: 70%;
            display: flex;
        }

        .inputs, .btns {
            flex: 2;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .textarea {
            flex: 6;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .textarea textarea {
            width: 90%;
            height: 90%;
            resize: none;
        }

        .btns {

        }

        button {
            width: 80%;
            margin-bottom: 4%;
        }
    </style>
</head>
<body>
<div style="margin: 0 auto; width: 50%; height: 80%; border: 2px #00f solid;">
    <div class="header">
        <img src="../static/img/ico_7l.gif"/>
        <img src="../static/img/fc_logo.jpg"/>
    </div>
    <div class="title">
        <h1 align="center">博彩投注站彩票投注助手</h1>
    </div>
    <div class="content">
        <div class="inputs">
            <button onclick="generation(1)">机投1注</button>
            <button onclick="generation(5)">机投5注</button>
            <button onclick="generation(10)">机投10注</button>
        </div>
        <div class="textarea">
            <textarea id="area" name="area"></textarea>
        </div>
        <div class="btns">
            <button onclick="deleteSelect()">删除</button>
            <button onclick="generation(0)">全部删除</button>
        </div>
    </div>
</div>
<script type="text/javascript">
    function randomEight(min, max) {
        let arr = []
        while (arr.length < 8) {
            let item = Math.floor(Math.random() * (max - min + 1)) + min;
            if (item <= 9) {
                item = "0" + item
            }
            if (arr.indexOf(item) === -1) {
                arr.push(item);
            }
        }
        return arr;
    }

    function generation(n) {
        let dom = document.getElementsByName("area")[0]
        dom.value = ''
        for (var i = 0; i < n; i++) {
            let arr = randomEight(1, 35)
            let text = dom.value;
            text += arr + '\n'
            dom.value = text
        }
    }

    function deleteSelect() {
        let s = document.getElementsByName("area")[0].selectionStart
        let e = document.getElementsByName("area")[0].selectionEnd
        let dom = document.getElementsByName("area")[0]
        text = dom.value
        temp = text.slice(s, e + 1)
        text = text.replace(temp, '')
        dom.value = text
    }
</script>
</body>
</html>